import request from '@/utils/request'
var qs = require('qs')

export function loginByUsername(username, password, openid) {
  try {
    // for x-www-form-urlencoded
    var data = qs.stringify({
      username: username,
      password: password
    })

    return request({
      method: 'post',
      url: '/gateway/login',
      data: data,
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
      }
    })
  } catch (e) {
    console.log('login error!')
    console.log(e)
  }
}

export function logout(token) {
  return request({
    url: '/gateway/logout',
    method: 'post'
  })
}

export function getUserInfo() {
  return request({
    url: '/gateway/login/user',
    method: 'post'
  })
}

export function getMenuList() {
  return request({
    url: '/api/inner/portal/menu/user',
    method: 'get'
  })
}

